<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>云校通-教师-考试列表</title>
<jsp:include page="/WEB-INF/page/common/_header.jsp"></jsp:include>
<body ontouchstart style="background: #FFFFFF;">
	<div class="weui_tab tab-bottom">
        <div class="weui_tab_bd">
        	 <div class="weui-header bg-blue"> 
		  		<div class="weui-header-left"> <a onclick="back()" href="javascript:;" class="icon icon-109 f-white">返回</a> </div>
		    	<h1 class="weui-header-title">考试列表</h1>
		    </div>
		    <div class="weui_panel weui_panel_access mt0" style="margin-bottom: 55px;">
			    <div class="weui_media_box weui_media_small_appmsg">
                    <div class="weui_cells weui_cells_access mt0" id="examList">
                    	
                    </div>
                </div>
		    </div>
            <a href="<%=basePath%>/ls/exam/score/addExam">
                <div class="addBtnnew" id="addBtnnew">
					<div class="linea"></div>
					<div class="lineb"></div>
		        </div>
	        </a>
        </div>
   </div>
</body>
<jsp:include page="/WEB-INF/page/common/_footer.jsp"></jsp:include>
<script type="text/javascript">
$(function(){
	//页数 
    var page = 0;
    // 每页展示10个
    var size =10;
    $('.weui_panel').dropload({
        scrollArea : window,
        autoLoad : true,//自动加载
  		domDown : {//上拉
            domClass   : 'dropload-down',
            domRefresh : '<div class="dropload-refresh f15 "><i class="icon icon-20"></i>上拉加载更多</div>',
            domLoad    : '<div class="dropload-load f15"><span class="weui-loading"></span>正在加载中...</div>',
            domNoData  : '<div class="dropload-noData">没有更多数据了</div>'
        },
        domUp : {//下拉
            domClass   : 'dropload-up',
            domRefresh : '<div class="dropload-refresh"><i class="icon icon-114"></i>上拉加载更多</div>',
            domUpdate  : '<div class="dropload-load f15"><i class="icon icon-20"></i>释放更新...</div>',
            domLoad    : '<div class="dropload-load f15"><span class="weui-loading"></span>正在加载中...</div>'
        },
        loadDownFn : function(me){//加载更多
	        page++;
			window.params = {
				page: page,
	  	 		rows: size
			};	            
	       	$.ajax({
	          	url : basePath + "/ls/exam/score/examList/pageQuery",
	  	 		type : "post",
	  	 		dataType : "json",
	  	 		data : window.params,
	            success: function(data){
	         		 if(data.rows.length == 0 || window.params.page * window.params.rows >= data.data.total) {// 如果没有数据
	                      // 锁定
	                      me.lock();
	                      // 无数据
	                      me.noData();
	                  }
	                  // 为了测试，延迟1秒加载
	                  setTimeout(function(){
	                	  loadExamHtml(data);
	                    // 每次数据加载完，必须重置
	                    me.resetload();
	                  },200);
	              },
	              error: function(xhr, type){
	              }
	          });
        }
    });
});
function loadExamHtml(data) {
	if(data.rows.length > 0) {
		var html = "";
		for(var i in data.rows) {
			var itm = data.rows[i];
			html += '<a class="weui_cell" href="<%=basePath%>/ls/exam/score/examDetail/'+itm.examKey+'">\
			<div class="weui_cell_bd weui_cell_primary">\
			<p class="weui_media_desc f17 f-000">考试名称: '+itm.termName + itm.examName+'</p>\
			<p class="weui_media_desc pt10 f-15">考试年级: '+itm.gradeNames+'</p>\
			<p class="weui_media_desc pt10 f-15">考试时间：'+getTime(itm.examTime, "yyyy-MM-dd hh:mm")+'</p>\
			<p class="weui_media_desc pt10 f-15">登分截止时间：'+getTime(itm.regClosingTime, "yyyy-MM-dd hh:mm")+'</p>\
			</div><span class="weui_cell_ft"></span></a>';
		}
		$('#examList').append(html);
	}
}
</script>
</html>